const path = require('path')
function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    devServer: {
        // https: true,
        proxy: {
            '/apiDev': {
                // target: 'http://10.1.130.36:8081', // 线上36
                // target: 'http://10.5.10.42:8081', // 自己本地
                target: 'http://localhost:8080', // 学习
                changeOrigin: true,
                pathRewrite: { '/apiDev': '' },
            },
        },
    },
    transpileDependencies: [/node_modules[/\\\\](.*)[/\\\\]/],
    css: {
        sourceMap: true,
    },
    pluginOptions: {
        'style-resources-loader': {
            preProcessor: 'scss',
            patterns: [
                resolve('src/style/mixins/mixins.scss'),
                resolve('src/style/mixins.scss'),
                resolve('src/style/variables.scss'),
            ],
        },
    },
    productionSourceMap: false,
    chainWebpack: (config) => {
        config.resolve.alias
            .set('@', resolve('src'))
            .set('assets', resolve('src/assets'))
            .set('style', resolve('src/style'))
            .set('plugin', resolve('src/plugin'))
            .set('components', resolve('src/components'))
        config.entry('app').prepend('babel-polyfill')
    },
    configureWebpack: (config) => {
        if (process.env.NODE_ENV === 'production') {
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
        }
        if (process.env.NODE_ENV === 'production') {
            config.optimization.minimizer.forEach((plugin) => {
              if (plugin.options.terser) {
                plugin.options.terser.sourceMap = false; // 禁用 Terser 的 Source Map
              }
            });
          }
          if (process.env.NODE_ENV === 'devServe') {
            config.devtool = "source-map"

          }

    },
}
